package com.lizardmind.haofudoctor.ui.studio.signFamily

import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
import com.linxiao.framework.activity.BaseActivity
import com.linxiao.framework.adapter.BaseAdapter
import com.linxiao.framework.util.getDataBinding
import com.linxiao.framework.util.toasts
import com.lizardmind.haofudoctor.R
import com.lizardmind.haofudoctor.databinding.ActivitySimpleListBinding
import com.lizardmind.haofudoctor.databinding.ItemSignFamilyBinding
import com.lizardmind.haofudoctor.other.SignFamilyBean
import kotlinx.android.synthetic.main.activity_simple_list.*
import kotlinx.android.synthetic.main.include_title_text.*
import org.jetbrains.anko.sdk25.coroutines.onClick

class SignFamilyActivity : BaseActivity() {
    private val list= arrayListOf(
            SignFamilyBean("1","aaa","王春华",2,"四川省成都市成华区",3,"户主","1970-10-10"),
            SignFamilyBean("2","aaa","刘雯",2,"四川省成都市锦江区",3,"户主","1970-10-10")
    )
    private val adapter by lazy { BaseAdapter<SignFamilyBean,ItemSignFamilyBinding>(R.layout.item_sign_family,list) }

    val binding by lazy { getDataBinding<ActivitySimpleListBinding>(R.layout.activity_simple_list) }
    override fun onCreatRootView(): View? {
        return binding.root
    }

    override fun onInitView(savedInstanceState: Bundle?) {
        imgLeft.setImageResource(R.mipmap.back)
        imgLeft.onClick { finish() }
        titleText.text="签约家庭"

        recyclerView.layoutManager=LinearLayoutManager(this)
        recyclerView.adapter=adapter

        refreshLayout.setOnRefreshListener(object : RefreshListenerAdapter() {
            override fun onRefresh(refreshLayout: TwinklingRefreshLayout?) {
                super.onRefresh(refreshLayout)
            }

            override fun onLoadMore(refreshLayout: TwinklingRefreshLayout?) {
                super.onLoadMore(refreshLayout)
            }
        })

        adapter.onBind { itemBingding, position, data ->
            itemBingding.rLayout.onClick {
                startActivity(Intent(this@SignFamilyActivity,AllFamilyMomentActivity::class.java))
            }
        }
    }

}
